﻿using System;
using System.Collections.Generic;
using Ewk.MachineLearning.Persistance.Domain;

namespace Ewk.MachineLearning.Classification.Conversions.EntityVectorFactories
{
    /// <summary>
    /// Provides factories that can create a vector representation of an <see cref="Entity"/>.
    /// </summary>
    public class AbstractEntityVectorFactory
    {
        private static readonly Dictionary<Type, IEntityVectorFactory> Factories =
            new Dictionary<Type, IEntityVectorFactory>
                {
                    {typeof (Conversation), new ConversationVectorFactory()},
                    {typeof (Category), new CategoryVectorFactory()},
                    {typeof (Document), new DocumentVectorFactory()},
                };

        public static IEntityVectorFactory GetEntityVectorFactory<T>()
        {
            return GetEntityVectorFactory(typeof (T));
        }

        public static IEntityVectorFactory GetEntityVectorFactory(Type entityType)
        {
            if (Factories.ContainsKey(entityType))
            {
                return Factories[entityType];
            }

            throw new ArgumentException(string.Format("No factory for this Type of entity: {0}", entityType));
        }
    }
}